********************************************************************************
*                         Analysis of Scandinavia Experiment
********************************************************************************

* Code by Paul Musgrave (musgrave@umass.edu)
* For Paul Musgrave and Lindsey Guenther

* README: This code takes the cleaned data from the NATO Cyber Experiments
* conducted in April 2021 and turns them into a series of tables and charts
* for use in an appendix and manuscript, as well as pre-registered results.

* We do not analyze H4 because there were not a substantial fraction of don't
* know / no opinion / neither support nor oppose answers (only 9.32 percent).

********************************************************************************
*                                   Stata Stuff
********************************************************************************

clear all

set more off

set scheme plotplainblind

* You will have to change this to your personal settings!

global MyDocs "/Users/paulmusgrave/Dropbox/0001 Academic Projects/Ongoing/"
global MyProject "${MyDocs}0151 Lindsey NATO Cyber/Posted/Dataverse"

use "${MyProject}/apsascandinavia.dta"

gen     knowstable = knowstable1 + knowstable2
lab var knowstable "Knowledge (Stable)"

gen     knowscan = knowscan1 + knowscan2
lab var knowscan "Knowledge (Scan)"

gen     knowcheat = cheat1 + cheat2
lab var knowcheat "Knowledge (Cheat)"

gen know = knowscan + knowstable

********************************************************************************
*                       Organizing Code / Macros                               *
********************************************************************************


local demographics		 age white female hispanic college i.pid7 veteran
local economics          i.hhi i.employment
local technical			 attntotal order mobile
local trust              trustfeds
local feelings           raterussia ratescandi
local news               newsoftenalt newsimportantalt newspersonality
local internationalism   mi ci iso
local knowledge          knowscan knowstable knowcheat


********************************************************************************
*                       Core Analysis
********************************************************************************


* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*					Analysis of Support, Ordinal logit
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

* Brant tests say we can use ologit!!!!!

eststo h1m1:  quietly ologit scandiDVordinal i.scandicountry i.scandisevere

eststo h1m2:  quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical'

eststo h1m3:  quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `news' `knowledge'

eststo h1m4:  quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `trust' `feds'

eststo h1m5:  quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `news' `internationalism' `feelings'

eststo h1m6:  quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
                             `demographics' `economics' order mobile if attntotal == 3
							 
 ******** Tables
 esttab   h1m1 h1m2 h1m3 h1m4 h1m5 ///
				using "${MyProject}/ScandinaviaTableH1Ologit.tex", ///
 				  lab noomitted nobase varwidth(25) nodepvars compress replace ///
 				   mtitles("Base" "Controls" "Internet" "MI/CI" "Threat" "Knowledge") ///
           title("Scandinavia Experiment, Main DV (Ordinal), Ologit" \label{tab:scandih1}) ///
           eqlabel(none) longtable notes ///
           refcat( 1.scandicountry "Country Type" ///
                 1.scandisevere "Casualties" ///
                 age "Demographics" ///
                 , nolabel)


********* Main charts *********************************************************

* * * * * * * * * * * * * * Coefficient Plots

coefplot  (h1m1, label(Base, No Controls) offset(.3)) ///
         (h1m2, label(Base With Controls) offset(.2)) ///
         (h1m3, label(Knowledge) offset(.1)) ///
         (h1m4, label(Trust)) ///
         (h1m5, label(Internationalism) offset(-0.1)) /// 
		 (h1m6, label(Attentive Only) offset(-0.2)) , drop(_cons) ///
         keep(*.scandicountry *.scandisevere) ///
         noomitted nobase xline(0) ///
         title({bf: A: Scandinavia Scenario Results}, size(medium) span) ///
         subtitle({it:Ordinal Logistic Coefficients Shown}, size(small) span) ///
         caption("N: Base = 1405, Internationalism = 1270, Attentive = 1112, Others = 1344." ///
           , size(vsmall)) ///
         headings(1.scandicountry = "{bf:Country Type}" ///
           1.scandisevere = "{bf:Casualties}") ///
           name(coefbase,replace) legend(rows(6) ring(0) pos(5))


* * * * * * * * * * * * * * Effect Size Plots

mylabels 0(10)50, myscale(@/100) local(myla)
quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
               `demographics' `economics' `technical'
margins scandicountry, atmeans
marginsplot, title({bf: B: Predicted Effects of Treaty Status on Support for US Action}, size(medium) span) ///
            subtitle({it:By Country; Other Variables at Means}, size(small) span) ///
            plotdim(,elabels(1 "Strongly Oppose" 2 "Oppose" 3 "Somewhat Oppose" ///
                             4 "Neither" 5 "Somewhat Support" 6 "Support" ///
                              7 "Strongly Support")) ylab(`myla') ///
            name(h1scandicountry, replace) ///
            legend(rows(2) ring(2) pos(12) size(vsmall))

gr combine coefbase h1scandicountry, name(basecombined, replace) ///
    title({bf:Scandinavia Results}, size(large)) rows(2)
gr display basecombined, xsize(5) ysize(9)
gr export "${MyProject}/ScandinaviaCoefficientsPredicted.png", replace
gr export "${MyProject}/ScandinaviaCoefficientsPredicted.pdf", replace


* * * * * * * * * * * * * * Effect Size Plots Bar Chart


mylabels 0(10)50, myscale(@/100) local(myla)
quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
               `demographics' `economics' `technical'
margins, atmeans at(scandicountry==0) post
eststo scandi0


mylabels 0(10)50, myscale(@/100) local(myla)
quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
               `demographics' `economics' `technical'
margins, atmeans at(scandicountry==1) post
eststo scandi1

coefplot scandi0 scandi1, ///
	title({bf: B: Predicted Effects of Treaty Status on Support for US Action}, size(medium) span) ///
            subtitle({it:By Country; Other Variables at Means}, size(small) span) ///
	recast(bar) barw(0.15) ///
	ciopts(recast(rcap) color(gs8)) citop ///
	 ylab(1 "Strongly Oppose" 2 "Oppose" 3 "Somewhat Oppose" ///
					4 "Neither" 5 "Somewhat Support" 6 "Support" ///
					7 "Strongly Support") ///
	legend(order(1 "Sweden" 3 "Norway") ring(0) pos(2)) ///
	xtitle("Predicted Probability of Choosing Each Response") ///
	name(h1scandicountrybar, replace) xlab(`myla') 
 

gr combine coefbase h1scandicountrybar, name(basecombinedbar, replace) rows(2)
gr display basecombinedbar, xsize(5) ysize(9)
gr export "${MyProject}/ScandinaviaCoefficientsPredictedBar.png", replace
gr export "${MyProject}/ScandinaviaCoefficientsPredictedBar.pdf", replace
gr export "${MyProject}/ScandinaviaCoefficientsPredictedBar.eps", replace

* Horizontal Plot
coefplot scandi0 scandi1, ///
	title({bf: B: Predicted Effects of Treaty Status}, size(medium) span) ///
            subtitle({it:By Country; Other Variables at Means}, size(small) span) ///
	recast(bar) barw(0.15) ///
	ciopts(recast(rcap) color(gs8)) citop ///
	 ylab(1 "Strongly Oppose" 2 "Oppose" 3 "Somewhat Oppose" ///
					4 "Neither" 5 "Somewhat Support" 6 "Support" ///
					7 "Strongly Support") ///
	legend(order(1 "Sweden" 3 "Norway") ring(0) pos(2)) ///
	xtitle("Predicted Probability of Choosing Each Response", size(vsmall)) ///
	name(h1scandicountrybar, replace) xlab(`myla') 
	
gr combine coefbase h1scandicountrybar, name(basecombinedbar, replace) rows(1)
gr export "${MyProject}/ScandinaviaCoefficientsPredictedBarH.pdf", replace
gr export "${MyProject}/ScandinaviaCoefficientsPredictedBarH.eps", replace


* * * * * * * * * * * * * * Subgroup plots

*** veteran
eststo h1m2temp0: quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if veteran == 1
eststo h1m2temp1: quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if veteran == 2
coefplot  (h1m2temp0, label(Not Veteran) offset(.1)) ///
          (h1m2temp1, label(Veteran) offset(-.1)) ///
          , drop(_cons) coeflabels(,labsize(tiny)) nodraw ///
         keep(*.scandicountry *.scandisevere) ///
          noomitted nobase xline(0) ///
          title({bf:Veterans}, size(medium) span) ///
         headings(1.scandicountry = "{bf:Country Type}" ///
           1.scandisevere = "{bf:Casualties}") ///
            name(coefveterans,replace) legend(rows(2) ring(2) pos(12))


*** female
eststo h1m2temp0: quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if female == 0
eststo h1m2temp1: quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if female == 1
coefplot  (h1m2temp0, label(Not female) offset(.1)) ///
          (h1m2temp1, label(Female) offset(-.1)) ///
          , drop(_cons) coeflabels(,labsize(tiny)) nodraw ///
         keep(*.scandicountry *.scandisevere) ///
          noomitted nobase xline(0) ///
          title({bf:Gender}, size(medium) span) ///
         headings(1.scandicountry = "{bf:Country Type}" ///
           1.scandisevere = "{bf:Casualties}") ///
            name(coeffemales,replace) legend(rows(2) ring(2) pos(12))


*** know
eststo h1m2temp0: quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if know <= 1
eststo h1m2temp1: quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if know >= 2
coefplot  (h1m2temp0, label(Not knowledgeable) offset(.1)) ///
          (h1m2temp1, label(Knowledgeable) offset(-.1)) ///
          , drop(_cons) coeflabels(,labsize(tiny)) nodraw ///
         keep(*.scandicountry *.scandisevere) ///
          noomitted nobase xline(0) ///
          title({bf:Knowledgeable}, size(medium) span) ///
         headings(1.scandicountry = "{bf:Country Type}" ///
           1.scandisevere = "{bf:Casualties}") ///
            name(coefknows,replace) legend(rows(2) ring(2) pos(12))


*** pid3
eststo h1m2temp0: quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if pid3 == 0
eststo h1m2temp1: quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if pid3 == 1
eststo h1m2temp2: quietly ologit scandiDVordinal i.scandicountry i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if pid3 == 2
coefplot  (h1m2temp0, label(Democrats) offset(.1)) ///
          (h1m2temp1, label(Independents) offset(0)) ///
          (h1m2temp2, label(Republicans) offset(-.1)) ///
          , drop(_cons) coeflabels(,labsize(tiny)) nodraw ///
         keep(*.scandicountry *.scandisevere) ///
          noomitted nobase xline(0) ///
          title({bf:Party ID}, size(medium) span) ///
         headings(1.scandicountry = "{bf:Country Type}" ///
           1.scandisevere = "{bf:Casualties}") ///
            name(coefpid3,replace) legend(rows(2) ring(2) pos(12))


gr combine  coefpid3 coefknows coeffemales ///
            coefveterans, rows(2) title(Subgroup Variation) ///
            name(combinesubgroup, replace)
gr display  combinesubgroup, xsize(8) ysize(8)
graph export "${MyProject}/ScandinaviaSubgroupGraph.png", replace
graph export "${MyProject}/ScandinaviaSubgroupGraph.pdf", replace
graph close _all



* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*					Analysis of Support, Logit
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


eststo h1m1l:  quietly logit scandiDVdichot1 i.scandicountry i.scandisevere

eststo h1m2l:  quietly logit scandiDVdichot1 i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical'

eststo h1m3l:  quietly logit scandiDVdichot1 i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `news' `knowledge'

eststo h1m4l:  quietly logit scandiDVdichot1 i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `trust' `feds'

eststo h1m5l:  quietly logit scandiDVdichot1 i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `news' `internationalism' `feelings'

 ******** Tables
 esttab   h1m1l h1m2l h1m3l h1m4l h1m5l ///
				using "${MyProject}/ScandinaviaTableH1Logit.tex", ///
 				  lab noomitted nobase varwidth(25) nodepvars compress replace ///
 				   mtitles("Base" "Controls" "Internet" "MI/CI" "Threat" "Knowledge") ///
           title("Scandinavia Experiment, Main DV (Dichotomous), Logit" \label{tab:scandih1}) ///
           eqlabel(none) longtable notes ///
           refcat( 1.scandicountry "Country Type" ///
                 1.scandisevere "Casualties" ///
                 age "Demographics" ///
                 , nolabel)


* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*					Analysis of Support, OLS
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


eststo h1m1r:  quietly reg scandiDVdichot1 i.scandicountry i.scandisevere

eststo h1m2r:  quietly reg scandiDVdichot1 i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical'

eststo h1m3r:  quietly reg scandiDVdichot1 i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `news' `knowledge'

eststo h1m4r:  quietly reg scandiDVdichot1 i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `trust' `feds'

eststo h1m5r:  quietly reg scandiDVdichot1 i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `news' `internationalism' `feelings'

 ******** Tables
 esttab   h1m1r h1m2r h1m3r h1m4r h1m5r ///
				using "${MyProject}/ScandinaviaTableH1OLS.tex", ///
 				  lab noomitted nobase varwidth(25) nodepvars compress replace ///
 				   mtitles("Base" "Controls" "Internet" "MI/CI" "Threat" "Knowledge") ///
           title("Scandinavia Experiment, Main DV (Dichotomous), OLS" \label{tab:scandih1l}) ///
           eqlabel(none) longtable notes ///
           refcat( 1.scandicountry "Country Type" ///
                 1.scandisevere "Casualties" ///
                 age "Demographics" ///
                 , nolabel)



********************************************************************************
*                       Interaction Analysis
********************************************************************************

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*					Analysis of Support, Ordinal logit
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

* Brant tests say we can use ologit!!!!!

eststo h3m1:  quietly ologit scandiDVordinal i.scandicountry##i.scandisevere

eststo h3m2:  quietly ologit scandiDVordinal i.scandicountry##i.scandisevere ///
                             `demographics' `economics' `technical'

eststo h3m3:  quietly ologit scandiDVordinal i.scandicountry##i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `news' `knowledge'

eststo h3m4:  quietly ologit scandiDVordinal i.scandicountry##i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `trust' `feds'

eststo h3m5:  quietly ologit scandiDVordinal i.scandicountry##i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `news' `internationalism' `feelings'

 ******** Tables
 esttab   h3m1 h3m2 h3m3 h3m4 h3m5 ///
				using "${MyProject}/ScandinaviaTableh3Ologit.tex", ///
 				  lab noomitted nobase varwidth(25) nodepvars compress replace ///
 				   mtitles("Base" "Controls" "Internet" "MI/CI" "Threat" "Knowledge") ///
           title("Scandinavia Experiment, Main DV (Ordinal), Ologit" \label{tab:scandih3}) ///
           eqlabel(none) longtable notes ///
           refcat( 1.scandicountry "Country Type" ///
                 1.scandisevere "Casualties" ///
                 age "Demographics" ///
                 , nolabel)


********* Main charts *********************************************************

* * * * * * * * * * * * * * Coefficient Plots

coefplot  (h3m1, label(Base, No Controls) offset(.3)) ///
         (h3m2, label(Base With Controls) offset(.2)) ///
         (h3m3, label(Knowledge) offset(.1)) ///
         (h3m4, label(Trust)) ///
         (h3m5, label(Internationalism) offset(-0.1)) , drop(_cons) ///
         keep(*.scandicountry *.scandisevere) ///
         noomitted nobase xline(0) ///
         title({bf:Scandinavia Scenario Results}, size(medium) span) ///
         subtitle({it:Ordinal Logistic Coefficients Shown}, size(small) span) ///
         caption("N of 1344 for all models except for Internationalism, which has 1270." ///
           , size(vsmall)) ///
         headings(1.scandicountry = "{bf:Country Type}" ///
           1.scandisevere = "{bf:Casualties}") ///
           name(coefbase,replace) legend(rows(5) ring(0) pos(5))


* * * * * * * * * * * * * * Effect Size Plots

mylabels 0(10)50, myscale(@/100) local(myla)
quietly ologit scandiDVordinal i.scandicountry##i.scandisevere ///
               `demographics' `economics' `technical'
margins scandicountry, atmeans
marginsplot, title({bf:Predicted Effects of Treaty Status on Support for US Action}, size(medium) span) ///
            subtitle({it:By Country; Other Variables at Means}, size(small) span) ///
            plotdim(,elabels(1 "Strongly Oppose" 2 "Oppose" 3 "Somewhat Oppose" ///
                             4 "Neither" 5 "Somewhat Support" 6 "Support" ///
                              7 "Strongly Support")) ylab(`myla') ///
            name(h3scandicountry, replace) ///
            legend(rows(2) ring(2) pos(12) size(vsmall))

gr combine coefbase h3scandicountry, name(basecombined, replace) ///
    title({bf:Scandinavia Results}, size(large)) rows(2)
gr display basecombined, xsize(5) ysize(9)
gr export "${MyProject}/ScandinaviaCoefficientsPredictedInt.png", replace
gr export "${MyProject}/ScandinaviaCoefficientsPredictedInt.pdf", replace


* * * * * * * * * * * * * * Subgroup plots

*** veteran
eststo h3m2temp0: quietly ologit scandiDVordinal i.scandicountry##i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if veteran == 1
eststo h3m2temp1: quietly ologit scandiDVordinal i.scandicountry##i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if veteran == 2
coefplot  (h3m2temp0, label(Not Veteran) offset(.1)) ///
          (h3m2temp1, label(Veteran) offset(-.1)) ///
          , drop(_cons) coeflabels(,labsize(tiny)) nodraw ///
         keep(*.scandicountry *.scandisevere) ///
          noomitted nobase xline(0) ///
          title({bf:Veterans}, size(medium) span) ///
         headings(1.scandicountry = "{bf:Country Type}" ///
           1.scandisevere = "{bf:Casualties}") ///
            name(coefveterans,replace) legend(rows(2) ring(2) pos(12))


*** female
eststo h3m2temp0: quietly ologit scandiDVordinal i.scandicountry##i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if female == 0
eststo h3m2temp1: quietly ologit scandiDVordinal i.scandicountry##i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if female == 1
coefplot  (h3m2temp0, label(Not female) offset(.1)) ///
          (h3m2temp1, label(Female) offset(-.1)) ///
          , drop(_cons) coeflabels(,labsize(tiny)) nodraw ///
         keep(*.scandicountry *.scandisevere) ///
          noomitted nobase xline(0) ///
          title({bf:Gender}, size(medium) span) ///
         headings(1.scandicountry = "{bf:Country Type}" ///
           1.scandisevere = "{bf:Casualties}") ///
            name(coeffemales,replace) legend(rows(2) ring(2) pos(12))


*** know
eststo h3m2temp0: quietly ologit scandiDVordinal i.scandicountry##i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if know <= 1
eststo h3m2temp1: quietly ologit scandiDVordinal i.scandicountry##i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if know >= 2
coefplot  (h3m2temp0, label(Not knowledgeable) offset(.1)) ///
          (h3m2temp1, label(Knowledgeable) offset(-.1)) ///
          , drop(_cons) coeflabels(,labsize(tiny)) nodraw ///
         keep(*.scandicountry *.scandisevere) ///
          noomitted nobase xline(0) ///
          title({bf:Knowledgeable}, size(medium) span) ///
         headings(1.scandicountry = "{bf:Country Type}" ///
           1.scandisevere = "{bf:Casualties}") ///
            name(coefknows,replace) legend(rows(2) ring(2) pos(12))


*** pid3
eststo h3m2temp0: quietly ologit scandiDVordinal i.scandicountry##i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if pid3 == 0
eststo h3m2temp1: quietly ologit scandiDVordinal i.scandicountry##i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if pid3 == 1
eststo h3m2temp1: quietly ologit scandiDVordinal i.scandicountry##i.scandisevere ///
                `demographics' `economics' `technical' ///
                            if pid3 == 2
coefplot  (h3m2temp0, label(Democrats) offset(.1)) ///
          (h3m2temp1, label(Independents) offset(-.1)) ///
          (h3m2temp1, label(Republicans) offset(-.1)) ///
          , drop(_cons) coeflabels(,labsize(tiny)) nodraw ///
         keep(*.scandicountry *.scandisevere) ///
          noomitted nobase xline(0) ///
          title({bf:Party ID}, size(medium) span) ///
         headings(1.scandicountry = "{bf:Country Type}" ///
           1.scandisevere = "{bf:Casualties}") ///
            name(coefpid3,replace) legend(rows(2) ring(2) pos(12))


gr combine  coefpid3 coefknows coeffemales ///
            coefveterans, rows(2) title(Subgroup Variation) ///
            name(combinesubgroup, replace)
gr display  combinesubgroup, xsize(8) ysize(8)
graph export "${MyProject}/ScandinaviaSubgroupGraph.png", replace
graph export "${MyProject}/ScandinaviaSubgroupGraph.pdf", replace
graph close _all



* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*					Analysis of Support, Logit
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


eststo h3m1l:  quietly logit scandiDVdichot1 i.scandicountry##i.scandisevere

eststo h3m2l:  quietly logit scandiDVdichot1 i.scandicountry##i.scandisevere ///
                             `demographics' `economics' `technical'

eststo h3m3l:  quietly logit scandiDVdichot1 i.scandicountry##i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `news' `knowledge'

eststo h3m4l:  quietly logit scandiDVdichot1 i.scandicountry##i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `trust' `feds'

eststo h3m5l:  quietly logit scandiDVdichot1 i.scandicountry##i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `news' `internationalism' `feelings'

 ******** Tables
 esttab   h3m1l h3m2l h3m3l h3m4l h3m5l using "${MyProject}/ScandinaviaTableh3Logit.tex", ///
 				  lab noomitted nobase varwidth(25) nodepvars compress replace ///
 				   mtitles("Base" "Controls" "Internet" "MI/CI" "Threat" "Knowledge") ///
           title("Scandinavia Experiment, Main DV (Dichotomous), Logit" \label{tab:scandih3}) ///
           eqlabel(none) longtable notes ///
           refcat( 1.scandicountry "Country Type" ///
                 1.scandisevere "Casualties" ///
                 age "Demographics" ///
                 , nolabel)


* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*					Analysis of Support, OLS
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


eststo h3m1r:  quietly reg scandiDVdichot1 i.scandicountry##i.scandisevere

eststo h3m2r:  quietly reg scandiDVdichot1 i.scandicountry##i.scandisevere ///
                             `demographics' `economics' `technical'

eststo h3m3r:  quietly reg scandiDVdichot1 i.scandicountry##i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `news' `knowledge'

eststo h3m4r:  quietly reg scandiDVdichot1 i.scandicountry##i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `trust' `feds'

eststo h3m5r:  quietly reg scandiDVdichot1 i.scandicountry##i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `news' `internationalism' `feelings'

 ******** Tables
 esttab   h3m1r h3m2r h3m3r h3m4r h3m5r using "${MyProject}/ScandinaviaTableh3OLS.tex", ///
 				  lab noomitted nobase varwidth(25) nodepvars compress replace ///
 				   mtitles("Base" "Controls" "Internet" "MI/CI" "Threat" "Knowledge") ///
           title("Scandinavia Experiment, Main DV (Dichotomous), OLS" \label{tab:scandih3l}) ///
           eqlabel(none) longtable notes ///
           refcat( 1.scandicountry "Country Type" ///
                 1.scandisevere "Casualties" ///
                 age "Demographics" ///
                 , nolabel)


********************************************************************************
*                       Counterfactual Analysis
********************************************************************************

* Generate the dependent variable, which is change between the
* two treatment levels

gen     s_deaths   = scandiDVdichot1  if scandisevere     == 1
gen     s_nodeaths = scandiDVdichot1  if scandisevere     == 0

replace s_deaths   = scandiDValtdichot1  if scandiseverealt  == 1 & s_deaths == .
replace s_nodeaths = scandiDValtdichot1  if scandiseverealt  == 0 & s_nodeaths == .

gen     s_change_cf =  s_deaths-s_nodeaths
lab var s_change_cf "Counterfactual Change in Support for US Action"
lab def s_change_cf 0 "No change in support" 1 "Change in support"

* take a simple difference of means
ttest s_deaths = s_nodeaths /// difference of .0654804, t = 6.78

* compare different treatment arms

ttest s_deaths, by(scandisevere) /// difference of .0087138, t = 0.4062

* compare means by treaty condition
bysort scandicountry: ttest s_deaths = s_nodeaths
    * Norway .0527903 , t = 3.79, mean(deaths) = .8235
    * Sweden .0768194, t = 5.7358, mean(deaths) = .7749

clonevar scandiseverecondition = scandisevere
lab def  cflab 0 "Control" 1 "Treatment"
lab val  scandiseverecondition cflab

mylabels 0(10)90, myscale(@/100) local(myla)
graph hbar (mean) s_deaths s_nodeaths, ///
      title("A: Means of Support for U.S. Action by Casualty Levels", span) ///
      ytitle("Percent Supporting Action") ///
      ylab(`myla') ///
      legend(rows(2) position(9) order(1 "20 Deaths" 2 "Zero deaths")) ///
      name(cfmeans,replace) intensity(33)
	  

graph hbar (mean) s_deaths s_nodeaths, over(scandiseverecondition) ///
      title("B: Support for U.S. Action by Counterfactual Condition", span) ///
      ytitle("Percent Supporting Action") ///
      ylab(`myla') ///
      legend(rows(2) position(9) order(1 "20 Deaths" 2 "Zero deaths")) ///
      name(cfmeanscheck,replace)  intensity(33)

graph hbar (mean) s_deaths s_nodeaths, over(scandicountry) ///
      title("C: Support for U.S. Action by Country", span) ///
      ytitle("Percent Supporting Action") ///
      ylab(`myla') ///
      legend(rows(2) position(9) order(1 "20 Deaths" 2 "Zero deaths")) ///
      name(cfcountry,replace) intensity(33)
	  
graph combine cfmeans cfmeanscheck cfcountry, rows(3) ///
      name(cfgraph, replace) ///
      caption("N=1,405.")

graph display cfgraph, xsize(5) ysize(10)
gr export "${MyProject}/ScandiCFGraph.png", replace
gr export "${MyProject}/ScandiCFGraph.pdf", replace
gr export "${MyProject}/ScandiCFGraph.eps", replace

********************************************************************************
*                       Specific Strategy Analysis
********************************************************************************

eststo specm1: quietly ologit strat_specific_ordinal i.scandisevere i.scandicountry
eststo specm2: quietly ologit strat_specific_ordinal i.scandisevere i.scandicountry  ///
                            `demographics' `economics' `technical'
eststo specm3: quietly ologit strat_specific_ordinal i.scandisevere i.scandicountry  ///
                            `demographics' `economics' `technical' `news' `knowledge'
eststo specm4: quietly ologit strat_specific_ordinal i.scandisevere i.scandicountry  ///
                            `demographics' `economics' `technical' `trust' `feds'
eststo specm5: quietly ologit strat_specific_ordinal i.scandisevere i.scandicountry  ///
                            `demographics' `economics' `technical' `internationalism' `feelings'
esttab 	specm1 specm2 specm3 specm4 specm5 using "${MyProject}/ScandinaviaTableSpecificOlogit.tex", ///
				lab noomitted nobase varwidth(25) nodepvars compress replace ///
				mtitles("Base" "Controls" "Internet" "MI/CI" "Threat" "Knowledge") ///
        title("Scandinavia Experiment, Strategy Index, Ologit" \label{tab:scandih1}) ///
        eqlabel(none) longtable notes


* * * * * * Effect Size

mylabels 0(10)40, myscale(@/100) local(myla)
quietly ologit strat_specific_ordinal i.scandisevere i.scandicountry  ///
                            `demographics' `economics' `technical'
margins scandisevere, atmeans
marginsplot, title("") ///
             subtitle({it:By Casualties}) ///
             ylab(`myla') ///
             name(specificplausible, replace) nodraw  ///
             legend(order(1 "Nothing" 2 "Condemn" 3 "Sanctions" 4 "Espionage" ///
                          5 "Power Grid" 6 "Cyberattack") rows(2))


mylabels 0(10)40, myscale(@/100) local(myla)
quietly ologit strat_specific_ordinal i.scandisevere i.scandicountry  ///
                            `demographics' `economics' `technical'
margins scandicountry, atmeans
marginsplot, title("") ///
             subtitle({it:By Country}) ///
             ylab(`myla') ///
             name(specificivilian, replace) nodraw ///
             legend(order(1 "Nothing" 2 "Condemn" 3 "Sanctions" 4 "Espionage" ///
                          5 "Power Grid" 6 "Cyberattack") rows(2))

grc1leg2 specificplausible specificivilian, ///
            title("Scandinavia Strategy Retaliation (Ordinal Logit)") ///
            ycommon
gr export "${MyProject}/ScandinaviaEscalation.png", replace
gr export "${MyProject}/ScandinaviaEscalation.pdf", replace

* * * * * * Effect Size (Bar)

* By Attack Severity 
mylabels 0(10)40, myscale(@/100) local(myla)
quietly ologit strat_specific_ordinal i.scandisevere i.scandicountry  ///
                            `demographics' `economics' `technical'
eststo effectplot
margins, atmeans at(scandisevere==1) post
eststo scandiescalatesevere1


* Coefficient Plot


eststo specificm1:  quietly ologit strat_specific_ordinal i.scandicountry i.scandisevere

eststo specificm2:  quietly ologit strat_specific_ordinal i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical'

eststo specificm3:  quietly ologit strat_specific_ordinal i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `news' `knowledge'

eststo specificm4:  quietly ologit strat_specific_ordinal i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `trust' `feds'

eststo specificm5:  quietly ologit strat_specific_ordinal i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical' ///
                             `news' `internationalism' `feelings'

eststo specificm6:  quietly ologit strat_specific_ordinal i.scandicountry i.scandisevere ///
                             `demographics' `economics' order mobile if attntotal == 3
							 


coefplot  (specificm1, label(Base, No Controls) offset(.3)) ///
         (specificm2, label(Base With Controls) offset(.2)) ///
         (specificm3, label(Knowledge) offset(.1)) ///
         (specificm4, label(Trust)) ///
         (specificm5, label(Internationalism) offset(-0.1)) /// 
		 (specificm6, label(Attentive Only) offset(-0.2)) , drop(_cons) ///         
		 keep(*.scandicountry *.scandisevere) ///
         noomitted nobase xline(0) ///
         title({bf:A: Support for Retaliation}, size(medium) span) ///
         subtitle({it:Ordinal Logistic Coefficients Shown}, size(small) span) ///
         caption("N: Base = 1405, Internationalism = 1270, Attentive = 1112, Others = 1344." ///
           , size(vsmall)) ///
         headings(1.scandicountry = "{bf:Country Type}" ///
           1.scandisevere = "{bf:Casualties}") ///
           name(coefescalation,replace) legend(rows(6) ring(0) pos(5) size(tiny))

quietly ologit strat_specific_ordinal i.scandisevere i.scandicountry  ///
                            `demographics' `economics' `technical'
margins, atmeans at(scandisevere==0) post
eststo scandiescalatesevere0


coefplot scandiescalatesevere1 scandiescalatesevere0, ///
            title({bf: B: By Casualties}, size(medium) span) ///
			subtitle({it:Other Variables at Means}, size(small) span) ///
	recast(bar) barw(0.15) ///
	ciopts(recast(rcap) color(gs8)) citop ///
	 ylab(1 "Nothing" 2 "Condemn" 3 "Sanctions" ///
					4 "Espionage" 5 "Power Grid" 6 "Cyberattack") ///
	legend(order(1 "No Deaths" 3 "20 Deaths") ring(0) pos(2)) ///
	xtitle("Predicted Probability of Choosing Each Response") ///
	name(specificcasualtybar, replace) xlab(`myla') 


* By Treaty Status
mylabels 0(10)40, myscale(@/100) local(myla)
quietly ologit strat_specific_ordinal i.scandisevere i.scandicountry  ///
                            `demographics' `economics' `technical'
margins, atmeans at(scandicountry==1) post
eststo sescalate1


quietly ologit strat_specific_ordinal i.scandisevere i.scandicountry  ///
                            `demographics' `economics' `technical'
margins, atmeans at(scandicountry==0) post
eststo sescalate0


coefplot sescalate0 sescalate1 , ///
            title({bf: C: By Country},size(medium) span) ///
			subtitle({it:Other Variables at Means}, size(small) span) ///
	recast(bar) barw(0.15) ///
	ciopts(recast(rcap) color(gs8)) citop ///
	 ylab(1 "Nothing" 2 "Condemn" 3 "Sanctions" ///
					4 "Espionage" 5 "Power Grid" 6 "Cyberattack") ///
	legend(order(1 "Sweden" 3 "Norway") ring(0) pos(2)) ///
	xtitle("Predicted Probability of Choosing Each Response") ///
	name(specifictreatybar, replace) xlab(`myla') 
	
	

gr combine  specificcasualtybar specifictreatybar, ycommon ///
			name(specificbar,replace)
			
gr combine coefescalation specificbar, rows(2) 


gr export "${MyProject}/ScandinaviaEscalationBar.png", replace
gr export "${MyProject}/ScandinaviaEscalationBar.pdf", replace	
gr export "${MyProject}/ScandinaviaEscalationBar.eps", replace	

 ologit scandiDVordinal i.scandicountry i.scandisevere ///
                             `demographics' `economics' `technical'
margins scandicountry, contrast(effects nowald)

 ologit strat_specific_ordinal i.scandisevere i.scandicountry  ///
                            `demographics' `economics' `technical'
margins scandicountry,  contrast(effects nowald)

* Presentation Plot


coefplot sescalate0 sescalate1 , ///
            title({bf: B: By Country},size(medium) span) ///
			subtitle({it:Other Variables at Means}, size(small) span) ///
	recast(bar) barw(0.15) ///
	ciopts(recast(rcap) color(gs8)) citop ///
	 ylab(1 "Nothing" 2 "Condemn" 3 "Sanctions" ///
					4 "Espionage" 5 "Power Grid" 6 "Cyberattack") ///
	legend(order(1 "Sweden" 3 "Norway") ring(0) pos(2)) ///
	xtitle("Predicted Probability of Choosing Each Response") ///
	name(specifictreatybar, replace) xlab(`myla') 
	
gr combine coefescalation specifictreatybar, rows(1)
gr export "${MyProject}/ScandinaviaEscalationBarSelect.pdf", replace	
gr export "${MyProject}/ScandinaviaEscalationBarSelect.eps", replace	

